//
//  PeopleTableViewCell.m
//  QT
//
//  Created by 甘世清 on 2025/1/2.
//

#import "PeopleTableViewCell.h"

@implementation PeopleTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    [self.contentView addSubview:self.headerView];
    [self.contentView addSubview:self.nameLabel];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(50);
            make.left.equalTo(self.contentView).offset(16);
        make.top.equalTo(self.contentView).offset(10);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerView).offset(4);
        make.left.equalTo(self.headerView.mas_right).offset(10);
        make.height.mas_equalTo(20);
    }];
    
    [self.contentView addSubview:self.genderImage];
    [self.genderImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.nameLabel);
            make.size.mas_equalTo(13);
        make.left.equalTo(self.nameLabel.mas_right).offset(2);
    }];
    
    [self.contentView addSubview:self.messageLabel];
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(2);
        make.left.equalTo(self.headerView.mas_right).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-12);
    }];
    
    UIView * lineView = [[UIView alloc]init];
    lineView.backgroundColor = SQHexColor(@"#000000", 0.1);
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.headerView);
            make.right.equalTo(self.contentView.mas_right).offset(-10);
            make.height.mas_equalTo(0.4);
            make.bottom.equalTo(self.contentView.mas_bottom);
    }];
    
    self.FS_cellBottomView = self.messageLabel;
}

- (void)setModel:(PictureModel *)model{
    _model = model;
    [self.headerView.headerImage sd_setImageWithURL:SQURLImage(model.portrait) placeholderImage:SQGetImage(@"2")];
    self.nameLabel.text = model.name;
    self.messageLabel.text = SQNSLocalString(@"这个人有点懒..");
    if (model.gender  == 1) {
        self.genderImage.image = SQGetImage(@"男");
    } else {
        self.genderImage.image = SQGetImage(@"女");
    }
}
- (UIImageView *)genderImage{
    if (!_genderImage) {
        _genderImage = [[UIImageView alloc]init];
        _genderImage.image = SQGetImage(@"女");
    }
    return _genderImage;
}
- (HeaderView *)headerView{
    if (!_headerView) {
        _headerView = [[HeaderView alloc]init];
        _headerView.layer.cornerRadius = 25;
        _headerView.layer.masksToBounds = YES;
        _headerView.headerImage.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _headerView;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = SQColor333333;
        _nameLabel.font = FONT_MEDIUM(16);
    }
    return _nameLabel;
}

- (UILabel *)messageLabel{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc]init];
        _messageLabel.font = FONT_MEDIUM(12);
        _messageLabel.textColor = SQColor333333;
        _messageLabel.backgroundColor = UIColor.clearColor;
        _messageLabel.numberOfLines = 0;
    }
    return _messageLabel;
}

@end
